package com.jiunuan.live.im.provider.service.impl;

import com.jiunuan.live.framework.redis.starter.key.IMCoreServerProviderCacheKeyBuilder;
import com.jiunuan.live.im.provider.service.ImOnlineService;
import jakarta.annotation.Resource;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

/**
 * @Author: JiuNuan
 * @CreateTime: 2024-08-17 10:27
 * @Description:
 */
@Service
public class ImOnlineServiceImpl implements ImOnlineService {
    @Resource
    private RedisTemplate<String,Object> redisTemplate;
    @Resource
    private IMCoreServerProviderCacheKeyBuilder cacheKeyBuilder;

    /**
     * 判断用户是否在线
     *
     * @param userId
     * @param appId
     * @return
     */
    @Override
    public Boolean isOnline(Long userId, Integer appId) {
        return redisTemplate.hasKey(cacheKeyBuilder.buildIMBindIpKey(appId,userId));
    }
}
